package network;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class TcpDictServer extends TcpEchoServer{
    //创建一个哈希容器 作为成员变量
    private Map<String,String> dict = new HashMap<>();

    public TcpDictServer(int prot) throws IOException {
        super(prot);

        //利用构造方法 在哈希容器里面 添加数据
        dict.put("hello","你好");
        dict.put("cat","小猫");
        dict.put("dog","小狗");
        dict.put("fuck","卧槽");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"没有查询到该单词！！！") + '\n';
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer server = new TcpDictServer(9090);
        server.start();
    }
}
